import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/users/login',
    method: 'post',
    data
  })
}

export function createUser(data) {
  return request({
    url: '/users/register', // 假设后端注册接口地址为 /users/register
    method: 'post',
    data
  })
}

export function checkUsernameExists(username) {
  return request({
    url: '/users/check_username',
    method: 'get',
    params: { username }
  })
}

export function getInfo(token) {
  return request({
    url: '/users/info',
    method: 'get',
    headers: {
      'Authorization': `Bearer ${token}`
    }
    // params: { access_token: token }
  })
}

export function logout(token) {
  return request({
    url: '/users/logout',
    method: 'post',
    headers: {
      'Authorization': `Bearer ${token}`
    }
  })
}
